package com.sky.service.impl;

import com.sky.entity.OrderDetail;
import com.sky.mapper.OrderDetailMapper;
import com.sky.service.OrderDetailService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * 订单详情业务接口实现类
 *
 * @Author Vsunks.v
 * @Date 2023/5/9 11:47
 * @Blog blog.sunxiaowei.net/996.mba
 * @Description:
 */
@Service
public class OrderDetailServiceImpl implements OrderDetailService {

    @Autowired
    OrderDetailMapper orderDetailMapper;

    /**
     * 批量保存订单详情
     *
     * @param orderDetails 订单详情们
     * @return 是否成功
     */
    @Override
    public boolean saveBacth(ArrayList<OrderDetail> orderDetails) {
        return orderDetailMapper.insertBatch(orderDetails) > 0;
    }

    /**
     * 根据订单id查询订单明细列表
     * @param orderId 订单id
     * @return 当前订单的所有订单明细
     */
    @Override
    public List<OrderDetail> listByOrderId(Long orderId) {
        // 调用orderDetailMapper查询并返回
        return orderDetailMapper.listByOrderId(orderId);
    }
}
